#include<bits/stdc++.h>
using namespace std;
long long n,m,l,v;
long long d[100100],a[100100],v0[100100],p[100100];
//vector<int> detc[100100],detp[100100];
int pnum[100100];
//int usedc[100100],usedp[100100];
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;
	cin>>T;
	while(T--){
		int cnt=0;
		cin>>n>>m>>l>>v;
		for(int i=0;i<n;i++){
			cin>>d[i]>>v0[i]>>a[i];
		}
		for(int i=0;i<m;i++){
			cin>>p[i];
		}
		sort(p,p+m);
		for(int i=0;i<n;i++){
			if(a[i]<0){
				if(v0[i]<v)continue;
				bool flag=false;
				for(int j=lower_bound(p,p+m,d[i])-p;j<m;j++){
					if((p[j]-d[i])*a[i]*2 < -(v0[i]*v0[i]-v*v))break;
					//cout<<"    "<<j<<' '<<(p[j]-d[i])*a[i]*2-(v0[i]*v0[i]-v*v)<<endl;//
					flag=true;
					pnum[j]++;
				}
				if(flag)cnt++;
			}else{
				bool flag=false;
				for(int j=lower_bound(p,p+m,d[i])-p;j<m;j++){
					if((p[j]-d[i])*a[i]*2 < -(v*v-v0[i]*v0[i]))continue;
					//cout<<"    "<<j<<' '<<(p[j]-d[i])*a[i]*2-(v0[i]*v0[i]-v*v)<<endl;//
					flag=true;
					pnum[j]++;
				}
				if(flag)cnt++;
			}
		}
		cout<<cnt<<' ';
		int ans=1;
		cout<<ans<<endl;
		for(int i=0;i<n;i++){
			d[i]=0;a[i]=0;v0[i]=0;
		}
		for(int i=0;i<m;i++){
			p[i]=0;pnum[i]=0;
		}
	}
}
//wobushiren
//wanquanbushiren
//gg
//buhuixiexianduanshu =(
